import Url from './base'
import { request } from '../fetch'

export const postDetail = async (
  article_id: string = '7204707115062411320'
) => {
  const [e, r] = await request<any>({
    url: Url.PostDetail,
    method: 'POST',
    data: { article_id }
  })
  if (e) return null
  return r?.data
}

export const postContent = async (
  id: string,
  data: Record<string, string | number> = {}
) => {
  const [e, r] = await request<unknown[]>({
    url: Url.PostContent,
    method: 'POST',
    headers: {
      'x-secsdk-csrf-token':
        '0001000000010353585a3f83061c0c5ffeb5793c16e236d0b637f3310bd56a21934f948a3bb7174b4eb72af709eb'
    },
    params: {
      aid: process.env.VITE_APP_BASE_AID,
      uuid: process.env.VITE_APP_BASE_UUID,
      spider: '0'
    },
    data: {
      client_type: 2608,
      item_id: id,
      item_type: 2,
      cursor: '0',
      limit: 20,
      sort: 0, // 0 最新 1 最热
      ...data
    }
  })
  if (e) return null
  return r?.data
}
